package org.beanutopia.example;

import org.beanutopia.HTMap;
import org.beanutopia.PropertyUtils;
import org.beanutopia.UpdatableProperty;
import static org.beanutopia.example.Rectangle.Properties.*;
import static org.beanutopia.constraint.Constraints.nonNegativeInteger;
import static org.beanutopia.constraint.Constraints.notNull;

/**
 * @author ymeymann
 * @since Feb 26, 2007 9:47:27 AM
 */
public class Rectangle extends HTMap {
  private static final long serialVersionUID = -6021560736716083779L;
  //Rectangle<D extends Rectangle> extends SimpleBean<D>
  @SuppressWarnings({"serial"})
  interface Properties {
    UpdatableProperty<Rectangle, Integer> length =
          new UpdatableProperty<Rectangle, Integer>(0, notNull(), nonNegativeInteger()) {};
    UpdatableProperty<Rectangle, Number> width =
          new UpdatableProperty<Rectangle, Number>(0, notNull()) {};
  }

  public Rectangle(UpdatableProperty<? super Rectangle, ?>.Value... args) {
    PropertyUtils.populate(this, args);
  }

  public Rectangle(Integer l, Number w) {
    this(length.value(l), width.value(w));
  }

}

